//
//  HYWarningRecordView.m
//  TJHYHardwareProduct
//
//  Created by Kendama on 2018/1/22.
//  Copyright © 2018年 Kendama. All rights reserved.
//

#import "HYWarningRecordView.h"
#import "HYDateButtonView.h"

@implementation HYWarningRecordView

- (HYDateButtonView *)startView
{
    if(!_startView)
    {
        UIView *superView = self.headView;
        _startView = [[HYDateButtonView alloc]init];
        [superView addSubview:_startView];
//        _startView.dateLabel.text = @"2017-05-20";
        _startView.layer.cornerRadius = px1920Height(94)/2;
        _startView.layer.borderWidth = 0.6;
        _startView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
    return _startView;
}
- (HYDateButtonView *)endView
{
    if(!_endView)
    {
        UIView *superView = self.headView;
        _endView = [[HYDateButtonView alloc]init];
        [superView addSubview:_endView];
        _endView.dateLabel.text = @"2017-05-20";
        _endView.layer.cornerRadius = px1920Height(94)/2;
        _endView.layer.borderWidth = 0.6;
        _endView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
    return _endView;
}

- (UITableView *)tableView
{
    if(!_tableView)
    {
        UIView *superView = self;
        _tableView = [[UITableView alloc]init];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.estimatedSectionFooterHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
        [superView addSubview:_tableView];
    }
    return _tableView;
}

- (UIView *)headView
{
    if(!_headView)
    {
        UIView *superView = self;
        _headView = [[UIView alloc]init];
        [superView addSubview:_headView];
        _headView.backgroundColor = [UIColor whiteColor];
    }
    return _headView;
}


- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    CGFloat edge = px1080Width(20);
    superView.backgroundColor = rgba(245,245,245,1);

    [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(30));
        make.left.right.mas_equalTo(superView);
        make.height.mas_equalTo(px1920Height(175));
    }];
    
    UILabel *chooseLabel = [[UILabel alloc] init];
    [_headView addSubview:chooseLabel];
    chooseLabel.textColor = [UIColor darkGrayColor];
    chooseLabel.text = @"选择日期";
    chooseLabel.font = fontWithSize(14);
    [chooseLabel sizeToFit];
    [chooseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_headView.mas_centerY);
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(54));
    }];

    [self.startView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(px1920Height(94));
        make.width.mas_equalTo(px1080Width(350));
        make.centerY.mas_equalTo(_headView.mas_centerY);
        make.left.mas_equalTo(chooseLabel.mas_right).with.offset(edge);
    }];
    
//    UILabel *label = [[UILabel alloc] init];
//    [_headView addSubview:label];
//    label.textColor = [UIColor darkGrayColor];
//    label.text = @"至";
//    label.font = fontWithSize(14);
//    [label sizeToFit];
//    [label mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.mas_equalTo(_headView.mas_centerY);
//        make.left.mas_equalTo(_startView.mas_right).with.offset(edge);
//    }];
//
//    [self.endView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.height.mas_equalTo(px1920Height(94));
//        make.width.mas_equalTo(px1080Width(350));
//        make.centerY.mas_equalTo(_headView.mas_centerY);
//        make.left.mas_equalTo(label.mas_right).with.offset(edge);
//    }];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_headView.mas_bottom).with.offset(edge);
        make.left.right.bottom.mas_equalTo(superView);
    }];
}

@end
